<?php
	include("../Includes/FusionCharts.php");
	include("../Includes/FusionCharts_Gen.php");
	include("../Includes/DBConn.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>UPLB DV</title>
		
		<script language="Javascript" src="../js/FusionCharts.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.min.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
		<script type="text/javascript">

		$(document).ready(function() {
			$("a#example1").fancybox();

			$("a#example2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

			$("a#example3").fancybox({
				'transitionIn'	: 'none',
				'transitionOut'	: 'none'	
			});

			$("a#example4").fancybox({
				'opacity'		: true,
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'none'
			});

			$("a#example5").fancybox();

			$("a#example6").fancybox({
				'titlePosition'		: 'outside',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});

			$("a#example7").fancybox({
				'titlePosition'	: 'inside'
			});

			$("a#example8").fancybox({
				'titlePosition'	: 'over'
			});

			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
			}
		});

			$("#various1").fancybox({
					'titlePosition'		: 'inside',
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
			});

			$("#various2").fancybox();

			$("#various3").fancybox({
					'width'				: '75%',
					'height'			: '75%',
					'autoScale'			: false,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'type'				: 'iframe'
			});

			$("#various4").fancybox({
					'padding'			: 0,
					'autoScale'			: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
			});

		});

	</script>

		<link rel="stylesheet" href="../fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />

	</HEAD>

	<BODY bgcolor="white">
	<CENTER>
			<?php
				

			
				$subject = $_GET['subject'];
				//echo $subject;
				if($subject=="default"){
					$snfirst = 2007;
					$snlast = 36018;
					$yearfirst = 2007;
					$yearlast = 2008;
					$semester = 1;
					$graph = 'Column3D';
				}
				else{
					$snfirst = $_POST['sn_first'];
					$snlast = $_POST['sn_last'];
					$yearfirst = $_POST['sn_first'];
					$yearlast = 2008;
					$semester = 1;
					$graph = 'Column3D';
					
					
				}
				
				$snnumber = $snfirst.$snlast;
				$studentnumber = $snfirst."-".$snlast;
				$academicyear = $yearfirst.$yearlast;
				$ayear = $yearfirst."-".$yearlast;
					
					// Connect to the DB
				$link = connectToDB();

				//$strXML will be used to store the entire XML document generated
				//Generate the graph element
				//fetch the name of the specified student number
				$strQuery0 = "select * from student where studentNumber='$snnumber'";
				$result0 = mysql_query($strQuery0) or die(mysql_error());
				$ors = mysql_fetch_array($result0);
				$fullname = $ors['firstName']." ".$ors['lastName'];
				
				if($semester == 1){
					$semname ="First";
				}
				else if($semester == 2){
					$semname = "Second";
				}
				else if($semester == 3){
					$semname = "Third";
				}
				
								
				if($semester2 == 1){
					$semname2 ="First";
				}
				else if($semester2 == 2){
					$semname2 = "Second";
				}
				else if($semester2 == 3){
					$semname2 = "Third";
				}
				
				$schoolyear = $semname." Semester ".$ayear;
							
				$strQuery1 = "select mayts from tempStudents where studentNumber='$snnumber'";
				$result1 = mysql_query($strQuery1) or die(mysql_error());
				$ors1 = mysql_fetch_array($result1);
				$maxallowed = $ors1['mayts'];
				$length = $yearfirst + $maxallowed;
				
							
				$FC = new FusionCharts($graph,"800","400");
				$FC->setSwfPath("../FusionCharts/");
				$strParam="caption=$fullname; subcaption=$schoolyear; xAxisName=Course; yAxisName=Grade; formatNumberScale=0; decimalPrecision=2; yaxisminvalue=0; yaxismaxvalue=10; numdivlines=9";
				$FC->setChartParams($strParam);
				
				//$strXML = "<graph caption='$fullname' subCaption='$schoolyear' showBorder='1' showNames='1'  formatNumberScale='0' decimalPrecision='2' yaxismaxvalue='10'> ";
				
				
					
					// 1.00
					$strQueryuno = "select * from tempSubjects where studentNumber='$snnumber' and academicYear>='$yearfirst' and academicYear<='$length' and grade='2.75'";
					$resultuno = mysql_query($strQueryuno) or die(mysql_error());
					$i=1;
					echo "<form action='v_gradedistribution.php?subject=$subject' target='graph' method='post'>";
					echo "<center>";
					echo "<h3>Subjects with the grade of 2.75</h3>";
					
					echo "<br/>";
					echo "<table border = 1 width = 40%>";	
							echo "<tr>";
							echo "<td>";
								echo "<center>";
								echo "<b>SUBJECT</b>";
								echo "</center>";
							echo "</td>";
							echo "<td>";
								echo "<center>";
								echo "<b>SEMESTER TAKEN</b>";
								echo "</center>";
							echo "</td>";
							echo "</tr>";
					while($orsuno = mysql_fetch_array($resultuno)) {
						echo "<tr>";
							echo "<td>";
								echo "<center>";
								echo $orsuno['courseCode'];
								echo "</center>";
							echo "</td>";
							echo "<td>";
								echo "<center>";
								if($orsuno['semester'] == 1){
									$semname ="First";
								}
								else if($orsuno['semester'] == 2){
									$semname = "Second";
								}
								else if($orsuno['semester'] == 3){
									$semname = "Third";
								}
								$schoolyear = $semname." Sem ".$orsuno['academicYear']."-".($orsuno['academicYear']+1);
								echo $schoolyear;
								echo "</center>";
							echo "</td>";
						echo "</tr>";
						
						$i++;
					}					
					echo "</table>";
					echo "<br/>";
					
					echo "<input type='submit' value='Back'/>";
					echo "</form>";
			?>
	</CENTER>
	</BODY>
</HTML>